package io;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class Dome1 {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = null;
        inputStream = new FileInputStream("d:/test.txt");
        try{
           /* while(true) {
                int b =  inputStream.read();
                if(b == -1) {
                    //文件读取完毕
                    break;
                }
                System.out.printf("0x%X ",b);
            }*/
            while(true) {
                byte[] bytes = new byte[1024];
                int n = inputStream.read(bytes);
                System.out.println("n=" + n);
                for (int i = 0; i < n; i++) {
                    System.out.printf("0x%X ",bytes[i]);
                }
                if(n == -1) {
                    break;
                }
                System.out.println();
            }
        } finally {
            inputStream.close();
        }
    }
}
